package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/3/13 14:16
 * @description
 */
public class Code680 {
    public static void main(String[] args) {
        System.out.println(new Code680().validPalindrome("ebcbbececabbacecbbcbe"));
    }

    public boolean validPalindrome(String s) {
        int l = s.length() - 1;
        for (int i = 0, j = l; i <= l; i++, j--) {
            char c1 = s.charAt(i), c2 = s.charAt(j);
            if (c1 != c2) {
                String s1 = s.substring(i, j);
                String s2 = s.substring(i + 1, j + 1);
                String s3 = new StringBuilder(s1).reverse().toString();
                String s4 = new StringBuilder(s2).reverse().toString();
                if (s1.equals(s3) || s2.equals(s4)) {
                    return true;
                } else {
                    return false;
                }
            }

        }
        return true;
    }
}
